package com.example.download.fragment

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.download.Help
import com.example.download.R
import com.example.download.adapter.home_itemAdapter
import com.example.download.bean.home_item
import com.example.download.Setting




class AFragment : Fragment() {
    private lateinit var homeView: RecyclerView
    private lateinit var iv_th_setting: ImageView
    private lateinit var homeItemAdapter: home_itemAdapter
    private lateinit var homeItemlist: List<home_item>
    private lateinit var cl_fa_button :ConstraintLayout
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_a, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        homeView = view.findViewById<RecyclerView>(R.id.fa_recyclerViewA)
        homeView.layoutManager = GridLayoutManager(requireContext(), 4, GridLayoutManager.VERTICAL, false)
        homeItemlist = listOf(
            home_item(iv_hi_imageURL=R.drawable.a1, tv_hi_title="A1"),
            home_item(iv_hi_imageURL=R.drawable.a2, tv_hi_title="A2"),
            home_item(iv_hi_imageURL=R.drawable.a3, tv_hi_title="A3"),
            home_item(iv_hi_imageURL=R.drawable.a4, tv_hi_title="A4"),
            home_item(iv_hi_imageURL=R.drawable.a5, tv_hi_title="A5"),
            home_item(iv_hi_imageURL=R.drawable.a6, tv_hi_title="A6"),
            home_item(iv_hi_imageURL=R.drawable.a7, tv_hi_title="A7"),
            home_item(iv_hi_imageURL=R.drawable.a8, tv_hi_title="A8")
        )
        homeItemAdapter = home_itemAdapter(homeItemlist)
        homeView.adapter = homeItemAdapter

        iv_th_setting = view.findViewById(R.id.iv_th_setting)
        iv_th_setting.setOnClickListener {
            val intent = Intent(requireContext(), Setting::class.java)
            startActivity(intent)
        }
        cl_fa_button = view.findViewById(R.id.cl_fa_button)
        cl_fa_button.setOnClickListener {
            val intent = Intent(requireContext(), Help::class.java)
            startActivity(intent)
        }
    }


}